import request from '@/utils/request';
import { AxiosPromise } from 'axios';

/**
 * 查询产品分组列表
 * @param query
 * @returns {*}
 */

export const listGroup = (query?: GroupVO): AxiosPromise<GroupVO[]> => {
  return request({
    url: '/wms/group/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品分组详细
 * @param id
 */
export const getGroup = (id: number): AxiosPromise<GroupVO> => {
  return request({
    url: '/wms/group/' + id,
    method: 'get'
  });
};

/**
 * 新增产品分组
 * @param data
 */
export const addGroup = (data: GroupVO) => {
  return request({
    url: '/wms/group',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品分组
 * @param data
 */
export const updateGroup = (data: GroupVO) => {
  return request({
    url: '/wms/group',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品分组
 * @param id
 */
export const delGroup = (id: number | Array<number|undefined>) => {
  return request({
    url: '/wms/group/' + id,
    method: 'delete'
  });
};

//产品子表

/**
 * 查询产品分组列表
 * @param query
 * @returns {*}
 */
export const getGroupLine = (query?: groupProduct): AxiosPromise<groupProduct[]> => {
  return request({
    url: '/wms/groupProduct/list',
    method: 'get',
    params: query
  });
};

/**
 * 删除产品分组
 * @param bo
 */
export const delGroupProduct = (bo: groupProduct): AxiosPromise<groupProduct[]> => {
  return request({
    url: '/wms/groupProduct/delete',
    method: 'delete',
    params: bo
  });
};

/**
 * 新增产品分组
 * @param data
 */
export const addGroupProduct = (data: groupProduct[]) => {
  return request({
    url: '/wms/groupProduct',
    method: 'post',
    data: data
  });
};

export interface GroupVO extends BaseEntity,PageQuery {
    /** id */
      id?: number;

    /** 产品名称 */
      name?: string;

    /** 编码 */
      spu?: string;

    /** 产品属性名 */
    attrValueName?: string;

    /** 是否商城商品 */
      isShop?: string;

    /** 是否销售模块 */
      isCrm?: string;

    /** 是否启用 */
      status?: string;

    /** 产品分类 */
      treeValue?: string;

    /** 商城分类 */
      mallMenuId?: number;

    /** 备注 */
      remark?: string;

}

export interface groupProduct extends BaseEntity,PageQuery {
  groupId?: number;
  productId?: number;
  sort?: number;
  productName?: string;
}
